package cn.domob.android.ads;

import android.app.Activity;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.webkit.WebView;
import android.widget.FrameLayout.LayoutParams;
import android.widget.Toast;
import java.net.URI;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;

class i
  implements E.a, I.a, h.a, k.a, n.a, r.a, x.b
{
  protected static final String A = "wtai://wp/mc;";
  private static J B = new J(i.class.getSimpleName());
  protected static final String l = "domob";
  protected static final String m = "mraid";
  protected static final String n = "inapp";
  protected static final String o = "download";
  protected static final String p = "report";
  protected static final String q = "launch";
  protected static final String r = "custom";
  protected static final String s = "expand";
  protected static final String t = "close";
  protected static final String u = "clk";
  protected static final String v = "imp";
  protected static final String w = "event";
  protected static final String x = "visit";
  protected static final String y = "url";
  protected static final String z = "phase";
  private String C = null;
  private String D = null;
  private String E;
  private String F = null;
  private String G = null;
  private String H = null;
  private String I = "";
  private String J = "";
  private boolean K = false;
  private boolean L = true;
  private boolean M = true;
  private boolean N = false;
  private int O;
  private Handler P = new Handler(Looper.getMainLooper());
  private long Q = 0L;
  private long R = 0L;
  protected Context a;
  protected Context b;
  protected DomobAdView c = null;
  protected l d = null;
  protected b e = new b();
  protected b f;
  protected boolean g = false;
  protected boolean h = false;
  protected boolean i = false;
  protected a j = a.a;
  protected c k = c.c;

  public i(DomobAdView paramDomobAdView, String paramString)
  {
    B.a("Init DomobAdController.");
    if (paramDomobAdView != null)
    {
      this.c = paramDomobAdView;
      this.a = paramDomobAdView.a();
      this.b = this.a;
    }
    this.C = paramString;
    if (paramString == null)
      this.C = j.a().a(this.a);
    j.a().b(this.C);
    I();
    J();
    h.a(this.a, this);
  }

  public i(String paramString)
  {
    B.a("Init DomobAdController.");
    this.C = paramString;
    if (paramString == null)
      this.C = j.a().a(this.a);
    j.a().b(this.C);
  }

  private void I()
  {
    if (j.a().e())
      return;
    d locald = new d(this.a, "domob_config");
    String str1 = locald.a("version", "1");
    String str2 = locald.a("config", "{\"com.admogo.AdMogoLayout\":\"1\",\"com.guohead.sdk.GHView\":\"2\",\"com.adview.AdViewLayout\":\"3\",\"appfactory.cn.adplatform.AdSageLayout\":\"4\"}");
    j.a().a(str1, str2);
  }

  private void J()
  {
    d locald = new d(this.a, "domob_config");
    j.a().c(locald.a("cookie_id", null));
    j.a().a(locald.a("disable", false), locald.a("timestamp", 0L), locald.a("time", 0));
    this.O = locald.a("interval", 20000);
  }

  private void K()
  {
    HashMap localHashMap = new HashMap();
    String str1 = this.d.c();
    if (str1 != null)
    {
      localHashMap.put("cookie_id", str1);
      j.a().c(str1);
    }
    int i2;
    if (this.d.f() != null)
      if (this.d.f().d())
      {
        i2 = 1000 * this.d.f().a();
        if (i2 > 0)
          break label336;
      }
    for (this.O = 0; ; this.O = i2)
      do
        while (true)
        {
          localHashMap.put("interval", Integer.valueOf(this.O));
          boolean bool = this.d.f().b();
          long l1 = System.currentTimeMillis();
          int i1 = this.d.f().c();
          localHashMap.put("timestamp", Long.valueOf(l1));
          localHashMap.put("disable", Boolean.valueOf(bool));
          localHashMap.put("time", Integer.valueOf(i1));
          B.a(this, "disable time stamp:" + l1);
          B.a(this, "disable time:" + i1);
          j.a().a(bool, l1, i1);
          String str2 = this.d.f().e();
          String str3 = this.d.f().f();
          if (j.a().e(str2))
          {
            localHashMap.put("version", this.d.f().e());
            localHashMap.put("config", this.d.f().f());
            j.a().a(str2, str3);
          }
          if (!localHashMap.isEmpty())
            new d(this.a, "domob_config").a(localHashMap);
          return;
          label336: if ((i2 <= 0) || (i2 >= 5000))
            break;
          this.O = 5000;
        }
      while (i2 < 5000);
  }

  private void L()
  {
    String str = this.d.d().u();
    if (!q.a(this.a, str))
      return;
    j.a().d(this.d.d().a());
  }

  private boolean M()
  {
    return (!this.g) && (!this.i) && (!this.h);
  }

  private void N()
  {
    this.g = false;
    this.h = false;
    this.i = false;
  }

  private void a(H paramH, l.b.a parama, boolean paramBoolean)
  {
    int i1 = parama.h();
    label14: String str1;
    if (i1 < 0)
    {
      i1 = 5;
      B.a("Expandable timeout = " + i1);
      paramH.a(i1);
      if (paramBoolean)
        paramH.a(new c.b()
        {
          public void a(c paramc)
          {
            i.H().b("Both banner and expandable part are ok in current creative. Show Ad.");
            i.this.a(i.this.f);
            if (!i.this.d.d().i().i())
              return;
            i.a(i.this, i.this.d.d().i());
          }

          public void b(c paramc)
          {
            i.H().e("FAILED to load domob expandable view.");
            i.this.a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
          }

          public void c(c paramc)
          {
            i.H().a("Timeout while loading expandable part. Show AD.");
            i.this.a(i.this.f);
          }
        });
      paramH.a(new c.a(paramH)
      {
        public void a(c paramc, String paramString)
        {
          if ((paramString.startsWith("domob")) && (Uri.parse(paramString).getHost().equals("close")))
          {
            ((m)i.this.c.g()).f();
            return;
          }
          i.this.a(this.a, paramString, false);
        }
      });
      str1 = parama.b();
      if (!F.e(str1))
        break label125;
      B.e("Content type of expandable is null or empty.");
      a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
    }
    do
    {
      return;
      if (i1 > this.O);
      i1 = this.O;
      break label14:
      label125: if (!str1.equals("url"))
        continue;
      String str4 = parama.c();
      B.a("Get an DomobWebView instance for EXPANDABLE and load with URL:" + str4);
      paramH.a(str4, null);
      return;
    }
    while (!str1.equals("content"));
    String str2 = parama.d();
    String str3 = parama.e();
    B.a(String.format("Get an DomobWebView instance for EXPANDABLE and load data = [%s] with base URL=[%s]", new Object[] { str3, str2 }));
    paramH.a(str2, str3);
  }

  private void a(l.b.a parama)
  {
    B.a("Show expandable part of current creative.");
    String str1 = this.c.g().a().getUrl();
    String str2 = this.c.g().b().getUrl();
    B.a(String.format("bannerURL:%s, ExURL:%s", new Object[] { str1, str2 }));
    ((m)this.c.g()).a(parama);
  }

  private void a(String paramString, r paramr)
  {
    z localz = new z(this.a);
    localz.getClass();
    z.c localc = new z.c(localz);
    localc.a = paramr.a().d().m();
    localc.d = paramr.c();
    localc.e = paramr.d();
    localc.f = paramr.e();
    localz.a(paramr.a().d().l(), z.h.b, paramString, localc, null);
  }

  private void a(String paramString1, String paramString2, int paramInt, String paramString3)
  {
    z localz = new z(this.a);
    localz.getClass();
    z.c localc = new z.c(localz);
    localc.d = paramString2;
    localc.e = paramInt;
    localc.f = paramString3;
    localz.a("http://e.domob.cn/event_report", z.h.e, paramString1, localc, null);
  }

  private void b(l paraml, int paramInt)
  {
    if (paraml != null)
    {
      this.d = paraml;
      K();
      if (paraml.d() != null)
      {
        z();
        L();
        B.b("Get ad response successfully.");
        return;
      }
      if (paraml.e() != null)
      {
        Object[] arrayOfObject = new Object[2];
        arrayOfObject[0] = Integer.valueOf(paraml.e().a());
        arrayOfObject[1] = paraml.e().b();
        Log.e("DomobSDK", String.format("Response contains error info. Error code is [%d] and error content is [%s]", arrayOfObject));
        switch (paraml.e().a())
        {
        default:
          return;
        case 1000:
          a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
          return;
        case 2000:
          a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
          return;
        case 3000:
          a(DomobAdManager.ErrorCode.INVALID_REQUEST);
          return;
        case 4000:
          a(DomobAdManager.ErrorCode.NO_FILL);
          return;
        case 5000:
        }
        a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
        return;
      }
      B.e("Unexpected resp, Try to request again after refresh interval.");
      return;
    }
    switch (paramInt)
    {
    default:
      Log.w("DomobSDK", "Connection Error. Please make sure that your network is available.");
    case 200:
    case 400:
    case 403:
    case 404:
    case 500:
    case 502:
    }
    while (true)
    {
      B.e("AdResponse instance is null. Try to request again after refresh interval.");
      a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
      return;
      Log.w("DomobSDK", "There is no ad response for the request this time.");
      continue;
      Log.w("DomobSDK", "Bad Request. Please make sure that your publisher ID or any other infomation is correct.");
      continue;
      Log.w("DomobSDK", "Your publisher ID is forbidden by web server. Please ask domob's support for help.");
      continue;
      Log.w("DomobSDK", "Your publisher ID is not available temporarily, e.g. Your app is being examined and verified.");
      continue;
      Log.w("DomobSDK", "Server Error.");
      continue;
      Log.w("DomobSDK", "Server Busy.");
    }
  }

  private void b(String paramString1, String paramString2)
  {
    z localz = new z(this.a);
    localz.getClass();
    z.c localc = new z.c(localz);
    localc.a = this.d.d().m();
    if (paramString2 != null)
      localc.h = paramString2;
    localz.a(this.d.d().l(), z.h.c, paramString1, localc, null);
  }

  private void l(String paramString)
  {
    b(paramString, null);
  }

  private void m(String paramString)
  {
    z localz = new z(this.a);
    localz.getClass();
    z.c localc = new z.c(localz);
    localc.a = this.d.d().m();
    localz.a(this.d.d().l(), z.h.h, paramString, localc, null);
  }

  private void n(String paramString)
  {
    new z(this.a).a(this.d.d().l(), z.h.g, paramString, null, null);
  }

  public void A()
  {
    if ((this.I != null) && (!this.I.equals("")))
    {
      if ((this.J != null) && (this.J.equals("mraid")));
      for (String str = "mraid"; ; str = "domob")
      {
        B.b("gen fake ad response:" + str);
        Object[] arrayOfObject = new Object[2];
        arrayOfObject[0] = str;
        arrayOfObject[1] = this.I;
        a(l.a(String.format("{\"sid\":\"search_id\",\"cid\":\"cookie_id\",\"ad\":{\"id\":\"12345\",\"format\":\"%s\",\"ct\":\"url\",\"width\":320,\"height\":50,\"url\":\"%s\",\"content\":\"\",\"base_url\":\"\",\"click_tracker\":\"\",\"imp_tracker\":\"h\",\"event_tracker\":\"\",\"tracker\":\"8ewfqd8ffqwer1325effff342f3444\",\"animation\":1,\"o\":\"h\",\"cls_btn\":0,\"imp_min\":5,\"imp_cls\":8,\"cache\":1440,\"pkg\":\"cn.domob.android.rm.demo\",\"mz_click_tracker\":\"\",\"mz_imp_tracker\":\"\"},\"control\":{\"refresh\":20,\"disable\":false,\"dis_time\":30,\"location\":true,\"ors\":{\"version\":\"2\",\"config\":{\"com.admogo.AdMogoLayout\":\"1\",\"com.guohead.sdk.GHView\":\"2\",\"com.adview.AdViewLayout\":\"3\",\"appfactory.cn.adplatform.AdSageLayout\":\"4\",\"cn.domob.test\":\"5\"}}}}", arrayOfObject)), 200);
        return;
      }
    }
    v();
  }

  public void B()
  {
    if (!M())
      return;
    l("load_success");
    this.g = true;
  }

  public void C()
  {
    if (!M())
      return;
    l("load_failed");
    this.i = true;
  }

  public void D()
  {
    if (!M())
      return;
    l("load_cancel");
    this.h = true;
  }

  public void E()
  {
    ((Activity)this.a).runOnUiThread(new Runnable()
    {
      public void run()
      {
        if (i.this.c.e() != null)
          i.this.c.e().onLandingPageClose();
        if (i.this.c.f() == null)
          return;
        i.this.c.f().onDomobAdOverlayDismissed(i.this.c);
      }
    });
    l("close_lp");
  }

  public void F()
  {
    m("la_success");
    if (this.c.f() == null)
      return;
    this.c.f().onDomobLeaveApplication(this.c);
  }

  public void G()
  {
    m("la_failed");
  }

  protected void a()
  {
    if (this.k == c.a);
    do
    {
      do
      {
        return;
        if (this.j != a.a)
          break label110;
      }
      while (!this.L);
      B.b("Start schedule new request. Refresh interval is " + this.O);
      if (this.O == 0)
      {
        B.a("AdView is auto refreshable but interval from ad response is 0. DON'T SCHEDULE.");
        return;
      }
      this.P.removeCallbacks(this.e);
      this.P.postDelayed(this.e, this.O);
      this.k = c.a;
      label110: return;
    }
    while (this.j != a.b);
    B.a("AdView is expanding, cancel current 'start()'.");
  }

  protected void a(int paramInt)
  {
    this.O = paramInt;
  }

  protected void a(long paramLong)
  {
    this.Q = paramLong;
    this.R = 0L;
  }

  protected void a(DomobAdManager.ErrorCode paramErrorCode)
  {
    B.b("FAILED to load AD.");
    this.N = false;
    a();
    ((Activity)this.a).runOnUiThread(new Runnable(paramErrorCode)
    {
      public void run()
      {
        if (i.this.c.e() != null)
          i.this.c.e().onFailedToReceiveFreshAd(i.this.c);
        if (i.this.c.f() == null)
          return;
        i.this.c.f().onDomobAdFailed(i.this.c, this.a);
      }
    });
  }

  protected void a(b paramb)
  {
    if (this.M)
    {
      int i1 = this.d.d().n();
      switch (i1)
      {
      default:
        int i4 = i1 - 2;
        if ((i4 < 0) || (i4 >= af.a.values().length))
          break label119;
        this.c.a(paramb, af.a(af.a.values()[i4]));
        return;
      case 0:
        this.c.a(paramb, null);
        return;
      case 1:
      }
      int i2 = af.a.values().length;
      int i3 = (int)(Math.random() * i2);
      this.c.a(paramb, af.a(af.a.values()[i3]));
      return;
      label119: B.e("Invalid animation type index.");
      this.c.a(paramb, null);
      return;
    }
    this.c.a(paramb, null);
  }

  public void a(l paraml, int paramInt)
  {
    b(paraml, paramInt);
  }

  public void a(r paramr)
  {
    a("install_success", paramr);
  }

  protected void a(String paramString)
  {
    this.C = paramString;
  }

  public void a(String paramString1, int paramInt, String paramString2)
  {
    a("up_alert", paramString1, paramInt, paramString2);
  }

  public void a(String paramString1, int paramInt, String paramString2, boolean paramBoolean, String paramString3)
  {
  }

  public void a(String paramString1, String paramString2)
  {
    B.a(String.format("LandingPage 内下载，地址为%s，infoURL为%s", new Object[] { paramString1, paramString2 }));
    if (paramString2 != null);
    while (true)
      try
      {
        if (paramString2.length() != 0)
        {
          HashMap localHashMap = F.a(Uri.parse(paramString2).getQuery());
          if (localHashMap.containsKey("url"))
            localHashMap.put("url", paramString1);
          String str2 = F.a(localHashMap);
          localObject = "domob://download?" + str2;
          b(null, (String)localObject, false);
          return;
        }
        String str1 = "domob://download?url=" + URLEncoder.encode(paramString1, "UTF-8");
        Object localObject = str1;
      }
      catch (Exception localException)
      {
        B.e(String.format("解析LandingPage中下载出现错误，地址为%s，infoURL为%s", new Object[] { paramString1, paramString2 }));
      }
  }

  protected void a(String paramString1, String paramString2, long paramLong)
  {
    a(this.d.d().k(), null, paramString1, paramString2, paramLong);
  }

  protected void a(String paramString1, HashMap<String, String> paramHashMap, String paramString2)
  {
    String str = this.d.d().m();
    z localz = new z(this.a);
    localz.getClass();
    z.b localb = new z.b(localz);
    localb.a = str;
    if (paramString2 != null)
      localb.b = paramString2;
    localz.a(paramString1, localb, paramHashMap);
  }

  protected void a(String paramString1, HashMap<String, String> paramHashMap, String paramString2, String paramString3, long paramLong)
  {
    z localz = new z(this.a);
    localz.getClass();
    z.f localf = new z.f(localz);
    localf.a = this.d.d().m();
    int[] arrayOfInt = new int[2];
    this.c.getLocationOnScreen(arrayOfInt);
    Object[] arrayOfObject = new Object[4];
    arrayOfObject[0] = Integer.valueOf(arrayOfInt[0]);
    arrayOfObject[1] = Integer.valueOf(arrayOfInt[1]);
    arrayOfObject[2] = Integer.valueOf(this.c.getWidth());
    arrayOfObject[3] = Integer.valueOf(this.c.getHeight());
    localf.d = String.format("%d,%d,%d,%d", arrayOfObject);
    localf.e = q.v(this.a);
    localf.f = q.w(this.a);
    localf.g = q.s(this.a);
    localf.h = paramString2;
    localf.b = paramString3;
    localf.i = paramLong;
    localz.a(paramString1, localf, paramHashMap);
  }

  protected void a(boolean paramBoolean)
  {
    B.a("Auto refresh is set to " + paramBoolean);
    this.L = paramBoolean;
  }

  protected boolean a(WebView paramWebView, String paramString, boolean paramBoolean)
  {
    while (true)
    {
      try
      {
        if (paramString.startsWith("domob"))
        {
          if (!"domob".equals(Uri.parse(paramString).getScheme()))
            break label802;
          B.a("Scheme domob://");
          return b(paramWebView, paramString, paramBoolean);
        }
        if (paramString.startsWith("mraid"))
        {
          Uri localUri = Uri.parse(paramString);
          if (!"mraid".equals(localUri.getScheme()))
            break label802;
          B.a("Scheme MRAID://");
          if ((localUri.getHost().equals("expand")) || (localUri.getHost().equals("open")))
          {
            B.b("do click report for mraid scheme");
            w();
            if (this.c.f() != null)
              this.c.f().onDomobAdClicked(this.c);
            N();
            ((ac)paramWebView).a(new ac.a()
            {
              public void a()
              {
                if (i.this.c.f() == null)
                  return;
                i.this.c.f().onDomobAdOverlayPresented(i.this.c);
              }

              public void b()
              {
                if (i.this.c.f() == null)
                  return;
                i.this.c.f().onDomobAdOverlayDismissed(i.this.c);
              }
            });
          }
          return ((ac)paramWebView).a(URI.create(paramString));
        }
        if ((paramString.startsWith("http")) || (paramString.startsWith("tel:")) || (paramString.startsWith("voicemail:")) || (paramString.startsWith("sms:")) || (paramString.startsWith("mailto:")) || (paramString.startsWith("geo:")) || (paramString.startsWith("wtai://wp/mc;")))
        {
          B.a("Handle other phone intents.");
          if (paramBoolean)
          {
            w();
            if (this.c.f() != null)
              this.c.f().onDomobAdClicked(this.c);
          }
          if (!paramString.startsWith("http"))
            break label796;
          Intent localIntent1 = new Intent("android.intent.action.VIEW", Uri.parse(paramString));
          if (F.d(this.a))
          {
            B.b("browser exists");
            localIntent1.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
            if (this.a.getPackageManager().resolveActivity(localIntent1, 65536) != null)
              break label790;
            B.b("BrowserActivity class not exist,set component null");
            localIntent1.setComponent(null);
          }
          for (i1 = 1; ; i1 = 0)
          {
            if (i1 != 0)
            {
              if (this.c.f() != null)
                this.c.f().onDomobLeaveApplication(this.c);
              this.a.startActivity(localIntent1);
            }
            if (i1 != 0)
              break label802;
            Intent localIntent2 = new Intent("android.intent.action.VIEW", Uri.parse(paramString));
            localIntent2.addFlags(268435456);
            if (paramString.startsWith("wtai://wp/mc;"))
            {
              B.a("Create intent for: wtai://wp/mc;");
              localIntent2 = new Intent("android.intent.action.VIEW", Uri.parse("tel:" + paramString.substring("wtai://wp/mc;".length())));
            }
            try
            {
              this.a.startActivity(localIntent2);
              if (this.c.f() == null)
                break label802;
              this.c.f().onDomobLeaveApplication(this.c);
              return true;
            }
            catch (ActivityNotFoundException localActivityNotFoundException1)
            {
              Log.w("DomobSDK", "Could not handle intent with URI: " + paramString + ". Is this intent unsupported on your phone?");
              return false;
            }
            B.b("browser not exist");
          }
        }
        B.a("Handle unknown intents.");
        if (this.c.f() != null)
          this.c.f().onDomobLeaveApplication(this.c);
        if (paramBoolean)
        {
          w();
          if (this.c.f() != null)
            this.c.f().onDomobAdClicked(this.c);
        }
        Intent localIntent3 = new Intent("android.intent.action.VIEW", Uri.parse(paramString));
        localIntent3.addFlags(268435456);
        try
        {
          this.a.startActivity(localIntent3);
          if (this.c.f() == null)
            break label802;
          this.c.f().onDomobLeaveApplication(this.c);
          return true;
        }
        catch (ActivityNotFoundException localActivityNotFoundException2)
        {
          Log.w("DomobSDK", "Could not handle intent with URI: " + paramString + ". Is this intent unsupported on your phone?");
          return true;
        }
      }
      catch (Exception localException)
      {
        B.e("Exception in click.");
        B.a(localException);
        return false;
      }
      label790: int i1 = 1;
      continue;
      label796: i1 = 0;
    }
    label802: return true;
  }

  protected void b()
  {
    this.P.removeCallbacks(this.e);
    this.k = c.c;
  }

  public void b(r paramr)
  {
    a("run", paramr);
  }

  protected void b(String paramString)
  {
    this.D = paramString;
  }

  public void b(String paramString1, int paramInt, String paramString2)
  {
    a("up_ok", paramString1, paramInt, paramString2);
  }

  protected void b(boolean paramBoolean)
  {
    B.a("Transition animation is set to " + paramBoolean);
    this.M = paramBoolean;
  }

  protected boolean b(WebView paramWebView, String paramString, boolean paramBoolean)
    throws Exception
  {
    Uri localUri = Uri.parse(paramString);
    String str1 = localUri.getHost();
    if (str1.equals("inapp"))
    {
      if (paramBoolean)
      {
        w();
        if (this.c.f() != null)
          this.c.f().onDomobAdClicked(this.c);
      }
      String str9 = URLDecoder.decode(localUri.getQueryParameter("url"), "UTF-8");
      B.a("Open landing page with URL:" + str9);
      if (this.b != null)
      {
        N();
        new x(this.b, str9, paramString, this).a().show();
        ((Activity)this.b).runOnUiThread(new Runnable()
        {
          public void run()
          {
            if (i.this.c.e() != null)
              i.this.c.e().onLandingPageOpening();
            if (i.this.c.f() == null)
              return;
            i.this.c.f().onDomobAdOverlayPresented(i.this.c);
          }
        });
      }
    }
    do
      while (true)
      {
        return true;
        if (str1.equals("download"))
        {
          if (paramBoolean)
          {
            w();
            if (this.c.f() != null)
              this.c.f().onDomobAdClicked(this.c);
          }
          String str8 = URLDecoder.decode(localUri.getQueryParameter("url"), "UTF-8");
          new r(this.a, localUri, this.d, this).i();
          B.a("Download app with URL:" + str8);
        }
        if (str1.equals("launch"))
        {
          if (paramBoolean)
          {
            w();
            if (this.c.f() != null)
              this.c.f().onDomobAdClicked(this.c);
          }
          new n(this.a, localUri, this).a();
        }
        if (str1.equals("expand"))
        {
          if (paramBoolean)
          {
            w();
            if (this.c.f() != null)
              this.c.f().onDomobAdClicked(this.c);
          }
          if (this.d.d().i() != null)
          {
            B.a("Expandable part url:" + this.d.d().i().c());
            B.a("Expandable part base and content:" + this.d.d().i().d() + " || " + this.d.d().i().e());
            a(this.d.d().i());
          }
          B.e("广告应答无Expandable部分，无法进行expand action。");
          return false;
        }
        if (str1.equals("report"))
        {
          String str2 = localUri.getPath();
          if ((str2 == null) || (str2.indexOf("/") == -1))
          {
            B.e("There is no report type.");
            return false;
          }
          String str3 = str2.substring(1);
          if (str3.equals("imp"))
          {
            HashMap localHashMap2 = F.a(localUri.getQuery());
            Object localObject2 = "s";
            if (localHashMap2.containsKey("phase"))
            {
              String str7 = (String)localHashMap2.get("phase");
              localHashMap2.remove("phase");
              localObject2 = str7;
            }
            a(this.d.d().k(), localHashMap2, (String)localObject2, "ac", 0L);
          }
          if (str3.equals("event"))
          {
            HashMap localHashMap1 = F.a(localUri.getQuery());
            Object localObject1 = this.d.d().l();
            if (localHashMap1.containsKey("url"))
            {
              String str6 = (String)localHashMap1.get("url");
              localHashMap1.remove("url");
              localObject1 = str6;
            }
            z localz = new z(this.a);
            localz.getClass();
            z.c localc = new z.c(localz);
            localc.a = this.d.d().m();
            localc.b = "ac";
            localz.a((String)localObject1, null, null, localc, localHashMap1);
          }
          if (str3.equals("clk"))
          {
            String str5 = localUri.getQuery();
            a(this.d.d().j(), F.a(str5), "ac");
            if (this.c.f() == null)
              continue;
            this.c.f().onDomobAdClicked(this.c);
          }
          if (str3.equals("visit"))
          {
            String str4 = localUri.getQueryParameter("url");
            new p(this.a, str4, null).b();
          }
          B.e("Unknown reprot type.");
        }
        if (!str1.equals("close"))
          break;
        this.c.k();
      }
    while (str1.equals("custom"));
    B.e("Handle unknown action : " + str1);
    return false;
  }

  protected void c()
  {
    if (this.k == c.b);
    do
    {
      do
      {
        return;
        if (this.j != a.a)
          break label101;
      }
      while (!this.L);
      this.P.removeCallbacks(this.e);
      long l1 = System.currentTimeMillis();
      this.R += l1 - this.Q;
      B.a("Pause schedule and the ad has shown " + this.R + "ms");
      this.k = c.b;
      label101: return;
    }
    while (this.j != a.b);
    B.a("AdView is expanding, pause() has been called. Cancel current 'pause()'.");
  }

  public void c(r paramr)
  {
    a("download_finish", paramr);
  }

  protected void c(String paramString)
  {
    this.E = paramString;
  }

  public void c(String paramString1, int paramInt, String paramString2)
  {
    a("up_cancel", paramString1, paramInt, paramString2);
  }

  protected void c(boolean paramBoolean)
  {
    this.N = paramBoolean;
  }

  protected void d()
  {
    if (this.k == c.a);
    do
    {
      do
      {
        return;
        if (this.j != a.a)
          break label120;
      }
      while ((!this.L) || (this.O == 0));
      this.Q = System.currentTimeMillis();
      long l1 = this.O - this.R;
      if (l1 <= 0L)
      {
        B.a("Maybe there is no ad, request no.");
        i();
        return;
      }
      B.a("Resume with remaining time:" + l1);
      this.P.postDelayed(this.e, l1);
      this.k = c.a;
      label120: return;
    }
    while (this.j != a.b);
    B.a("AdView is expanding, cancel current 'resume()'.");
  }

  public void d(r paramr)
  {
    a("download_failed", paramr);
  }

  protected void d(String paramString)
  {
    this.F = paramString;
  }

  public void d(String paramString1, int paramInt, String paramString2)
  {
    a("up_skip", paramString1, paramInt, paramString2);
  }

  protected void d(boolean paramBoolean)
  {
    this.K = paramBoolean;
  }

  protected long e()
  {
    long l1 = System.currentTimeMillis();
    return this.R + (l1 - this.Q);
  }

  public void e(r paramr)
  {
    a("download_start", paramr);
  }

  protected void e(String paramString)
  {
    this.G = paramString;
  }

  public void e(String paramString1, int paramInt, String paramString2)
  {
    a("download_finish", paramString1, paramInt, paramString2);
  }

  public void f(r paramr)
  {
    a("download_cancel", paramr);
  }

  protected void f(String paramString)
  {
    this.H = paramString;
  }

  public void f(String paramString1, int paramInt, String paramString2)
  {
    a("download_failed", paramString1, paramInt, paramString2);
  }

  protected boolean f()
  {
    return this.L;
  }

  public void g(r paramr)
  {
    a("download_repeat", paramr);
    if (this.a == null)
      return;
    ((Activity)this.a).runOnUiThread(new Runnable()
    {
      public void run()
      {
        Toast.makeText(i.this.a, "应用正在下载", 0).show();
      }
    });
  }

  public void g(String paramString)
  {
    try
    {
      if (this.d.d().t())
        b("lp_url", paramString);
      URI localURI = URI.create(paramString);
      String str1 = localURI.getScheme();
      String str2 = localURI.getHost();
      if (F.e(str1))
        return;
      if (((str1.equals("domob")) && (!F.e(str2)) && (str2.equals("inapp"))) || (str1.startsWith("http")))
        return;
      a(null, paramString, false);
      return;
    }
    catch (Exception localException)
    {
      B.e("Error while parsing landingpage URL.");
      B.a(localException);
    }
  }

  public void g(String paramString1, int paramInt, String paramString2)
  {
    a("download_start", paramString1, paramInt, paramString2);
  }

  protected boolean g()
  {
    B.a("Check settings and permissions.");
    if ((this.C != null) && (this.C.length() != 0))
    {
      if (F.a(this.a))
      {
        B.a("All permissions are ok.");
        return true;
      }
      Log.w("DomobSDK", "Permission denied.");
    }
    while (true)
    {
      return false;
      Log.w("DomobSDK", "Please set your PlacementID first.");
    }
  }

  protected void h()
  {
    monitorenter;
    while (true)
      try
      {
        if ((!this.K) && (!this.N))
        {
          i();
          return;
        }
      }
      finally
      {
        monitorexit;
      }
  }

  public void h(r paramr)
  {
  }

  public void h(String paramString)
  {
    if (a(null, paramString, false))
    {
      m("la_failsafe_success");
      return;
    }
    m("la_failsafe_failed");
  }

  public void h(String paramString1, int paramInt, String paramString2)
  {
    a("download_cancel", paramString1, paramInt, paramString2);
  }

  protected void i()
  {
    monitorenter;
    while (true)
    {
      try
      {
        if ((this.c.getVisibility() != 0) || (!this.c.i()) || (!this.c.b()) || (!this.c.c()))
          break label73;
        if (!this.N)
        {
          v();
          return;
        }
      }
      finally
      {
        monitorexit;
      }
      label73: this.P.removeCallbacks(this.e);
      this.P.postDelayed(this.e, this.O);
    }
  }

  public void i(r paramr)
  {
    a("download_md5_failed", paramr);
  }

  public void i(String paramString)
  {
    n(paramString);
  }

  public void i(String paramString1, int paramInt, String paramString2)
  {
    a("download_repeat", paramString1, paramInt, paramString2);
  }

  protected String j()
  {
    return this.C;
  }

  public void j(r paramr)
  {
    h.a().a(paramr);
  }

  protected void j(String paramString)
  {
    this.I = paramString;
  }

  public void j(String paramString1, int paramInt, String paramString2)
  {
  }

  protected int k()
  {
    return this.c.d();
  }

  protected void k(String paramString)
  {
    this.J = paramString;
  }

  public void k(String paramString1, int paramInt, String paramString2)
  {
    a("download_md5_failed", paramString1, paramInt, paramString2);
  }

  protected String l()
  {
    return this.c.h();
  }

  protected String m()
  {
    return this.D;
  }

  protected String n()
  {
    return this.E;
  }

  protected String o()
  {
    return this.F;
  }

  protected String p()
  {
    return this.G;
  }

  protected String q()
  {
    return this.H;
  }

  protected Context r()
  {
    return this.a;
  }

  protected DomobAdListener s()
  {
    return this.c.e();
  }

  protected boolean t()
  {
    return this.K;
  }

  protected l u()
  {
    return this.d;
  }

  protected void v()
  {
    if (!j.a().c(this.a))
    {
      if (!this.N)
      {
        b();
        B.b("Load after schedule request.");
        this.N = true;
        new k(this).a();
        return;
      }
      B.d("An ad is requesting.");
      return;
    }
    B.d("Ad has been disabled currently. Disable expire time = " + new Date(j.a().c()));
  }

  protected void w()
  {
    a(this.d.d().j(), null, null);
  }

  protected void x()
  {
    I.a().a(this.a, this);
    y();
  }

  protected void y()
  {
    this.K = true;
    this.N = false;
    this.k = c.c;
    a();
  }

  protected void z()
  {
    ((Activity)this.a).runOnUiThread(new Runnable()
    {
      public void run()
      {
        l.b localb = i.this.d.d();
        int i = (int)(localb.c() * q.u(i.this.a));
        int j = (int)(localb.d() * q.u(i.this.a));
        i.this.c.a(i, j);
        String str1 = localb.b();
        i.H().a("Ad Type from response is:" + str1);
        c localc;
        String str2;
        if (str1.equals("domob"))
        {
          i.this.f = new m(i.this.a);
          i.this.f.a(new b.a()
          {
            public void a()
            {
              i.this.c();
              i.this.j = i.a.b;
              if (i.this.c.f() == null)
                return;
              i.this.c.f().onDomobAdOverlayPresented(i.this.c);
            }

            public void b()
            {
              i.this.j = i.a.a;
              i.this.d();
              if (i.this.c.f() == null)
                return;
              i.this.c.f().onDomobAdOverlayDismissed(i.this.c);
            }
          });
          localc = i.this.f.a();
          if (localc instanceof ac)
            ((ac)localc).a(i.this);
          localc.setLayoutParams(new FrameLayout.LayoutParams(i, j));
          localc.a(new c.b()
          {
            public void a(c paramc)
            {
              i.H().a("Finished to load domob banner view.");
              l.b.a locala = i.this.d.d().i();
              if (locala != null)
              {
                i.H().b("There is expandable part in current creative.");
                i.a(i.this, (H)i.this.f.b(), locala, locala.g());
                if (locala.g())
                  return;
                i.H().b("Expandable preload is disabled in current creative. Show Ad.");
              }
              while (true)
              {
                i.this.a(i.this.f);
                return;
                i.H().b("Banner is ready and there is no expandable part in current creative. Show Ad.");
              }
            }

            public void b(c paramc)
            {
              i.H().e("FAILED to load domob banner view.");
              i.this.a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
            }

            public void c(c paramc)
            {
              i.this.a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
            }
          });
          localc.a(new c.a()
          {
            public void a(c paramc, String paramString)
            {
              i.H().b("Banner BaseWebView 拦截到 URL：" + paramString);
              i.this.a(paramc, paramString, true);
            }
          });
          str2 = localb.f();
          if ((str2 == null) || (str2.length() == 0))
            break label396;
          if (!str2.equals("url"))
            break label333;
          i.H().a("Get an DomobWebView instance and load with URL:" + localb.e());
          localc.a(localb.e(), null);
        }
        do
        {
          return;
          if (str1.equals("mraid"))
            i.this.f = new K(i.this.a);
          i.H().b("bad ad received");
          i.this.a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
          label333: return;
        }
        while (!str2.equals("content"));
        J localJ = i.H();
        Object[] arrayOfObject = new Object[2];
        arrayOfObject[0] = localb.h();
        arrayOfObject[1] = localb.g();
        localJ.a(String.format("Get an DomobWebView instance and load data = [%s] with base URL=[%s]", arrayOfObject));
        localc.a(localb.g(), localb.h());
        return;
        label396: i.H().e("Content type is not available.");
        i.this.a(DomobAdManager.ErrorCode.INTERNAL_ERROR);
      }
    });
  }

  static enum a
  {
    static
    {
      a[] arrayOfa = new a[2];
      arrayOfa[0] = a;
      arrayOfa[1] = b;
      c = arrayOfa;
    }
  }

  class b
    implements Runnable
  {
    b()
    {
    }

    public void run()
    {
      i.this.i();
    }
  }

  static enum c
  {
    static
    {
      c[] arrayOfc = new c[3];
      arrayOfc[0] = a;
      arrayOfc[1] = b;
      arrayOfc[2] = c;
      d = arrayOfc;
    }
  }
}

/* Location:           C:\Users\god\Desktop\liunianjishiben_V1.1_mumayi_3745b_dex2jar.jar
 * Qualified Name:     cn.domob.android.ads.i
 * JD-Core Version:    0.5.4
 */